LLVM=../llvm_install

CXX=$(LLVM)/bin/clang++
#CXX=g++

CXXFLAGS=$(shell $(LLVM)/bin/llvm-config --cxxflags) -Wall -Wextra -Werror -fno-diagnostics-show-option -Wno-unused-parameter -ggdb3 -O0

LDFLAGS=\
	-lclangASTMatchers -lclangFrontend -lclangSerialization -lclangDriver -lclangTooling \
	-lclangParse -lclangSema -lclangAnalysis -lclangEdit -lclangAST \
	-lclangLex -lclangBasic $(shell $(LLVM)/bin/llvm-config --ldflags) \
	$(shell $(LLVM)/bin/llvm-config --libs) 

CFLAGS=-Wall -Wextra -Werror

all: goto-checker example.o compile_commands.json
	./goto-checker example.c

goto-checker: main.o goto-checker.o
	$(CXX) $^ $(LDFLAGS) -o $@

compile_commands.json:
	echo [\{\"directory\":\"$(shell pwd)\",\"command\":\"whatever example.c\",\"file\":\"$(shell pwd)/example.c\"\}] > $@

clean:
	-rm goto-checker goto-checker.o example.o

distclean: clean
	-rm compile_commands.json

goto-checker.o: goto-checker.hpp
main.o: goto-checker.hpp
